#ifndef CONVERSATIONMODEL_H
#define CONVERSATIONMODEL_H

#include <QObject>
#include <QAbstractListModel>

class ConversationModel : public QAbstractListModel
{
    Q_OBJECT
private:
    class Item;

public:
    enum Role {
        Content = 0,
        MyMsg = 1,
        Color = 2,
    };

private:
    QList<Item> mConversationList;
    static QHash<int, QByteArray> sRoleNames;

public:
    explicit ConversationModel(QObject *parent = nullptr);
    virtual ~ConversationModel();

    void add(const QString& content, int color, bool myMsg = false);
    void clear(int count = 0);

    // QAbstractItemModel interface
public:
    int rowCount(const QModelIndex &parent) const override;
    QVariant data(const QModelIndex &index, int role) const override;
    QHash<int, QByteArray> roleNames() const override;
signals:

private:
    class Item {
    public:
        QString content;
        int color;
        bool myMsg;

        explicit Item(const QString& content, int color, bool myMsg);
        virtual ~Item();
    };
};

//Q_DECLARE_METATYPE(ConversationModel)
#endif // CONVERSATIONMODEL_H
